package com.xieyingwangluo.yxpart.api;


import com.xieyingwangluo.yxpart.bean.Result;
import com.xieyingwangluo.yxpart.bean.SkillDTO;
import com.xieyingwangluo.yxpart.logic.SkillLogic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Api(tags = "技能证书接口")
@Controller
@RequestMapping(value = "/api/v1/skill")
public class SkillBaseRest extends BaseRest {

    @Autowired
    private SkillLogic skillLogic;

    @ApiOperation(value = "添加技能证书", notes = "添加技能证书", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "numb", value = "证书编号", required = true, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "info", value = "描述", required = false, dataType = "String", paramType = "form"),
            @ApiImplicitParam(name = "user_id", value = "用户id", required = true, dataType = "String", paramType = "form")
    })
    @ResponseBody
    @PostMapping(value = "/add")
    public Result add(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                      SkillDTO skillDTO) {
        return skillLogic.add(skillDTO);
    }

    @ApiOperation(value = "修改技能证书", notes = "修改修改技能证书", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "技能证书noid", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "numb", value = "证书编号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "info", value = "描述", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "user_id", value = "不必传 用户id", required = false, dataType = "String", paramType = "query")
    })
    @ResponseBody
    @PutMapping(value = "/upd")
    public Result update(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                         @RequestParam("noid") String noid,
                         SkillDTO skillDTO) {
        return skillLogic.upd(noid, skillDTO);
    }
    //显示：用户教育经历编号（noid）

    @ApiOperation(value = "显示技能证书", notes = "显示显示技能证书", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "技能证书id", required = true, dataType = "String", paramType = "query")
    })
    @ResponseBody
    @GetMapping(value = "/selO")
    public Result selO(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                       @RequestParam("noid") String noid) {
        return skillLogic.getById(noid);
    }

    @ApiOperation(value = "模糊查询技能证书", notes = "模糊查询教育背景", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "numb", value = "证书编号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "info", value = "描述", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "user_id", value = "用户id", required = false, dataType = "String", paramType = "query")
    })
    @ResponseBody
    @PutMapping(value = "/selA")
    public Result selA(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                       SkillDTO skillDTO) {
        return skillLogic.selA(skillDTO);
    }

    @ApiOperation(value = "删除技能证书", notes = "显示显示技能证书", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noid", value = "技能证书id", required = true, dataType = "String", paramType = "query")
    })
    @ResponseBody
    @GetMapping(value = "/del")
    public Result del(@RequestHeader(name = "Authorization", defaultValue = "token") String token,
                      @RequestParam("noid") String noid) {
        return skillLogic.del(noid);
    }
}
